/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GM.impl;

import GM.Action;
import GM.AdGoal;
import GM.Agent;
import GM.ContributionLink;
import GM.Entity;
import GM.Event;
import GM.GMPackage;
import GM.Goal;
import GM.GoalDiagram;
import GM.Operation;
import GM.RefinementLink;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Goal Diagram</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasRLink <em>Has RLink</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasGoal <em>Has Goal</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasAdGoal <em>Has Ad Goal</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasEvent <em>Has Event</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasOper <em>Has Oper</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasEntity <em>Has Entity</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasAgent <em>Has Agent</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasAction <em>Has Action</em>}</li>
 *   <li>{@link GM.impl.GoalDiagramImpl#getHasCLink <em>Has CLink</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GoalDiagramImpl extends EObjectImpl implements GoalDiagram {
	/**
	 * The cached value of the '{@link #getHasRLink() <em>Has RLink</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasRLink()
	 * @generated
	 * @ordered
	 */
	protected EList<RefinementLink> hasRLink;

	/**
	 * The cached value of the '{@link #getHasGoal() <em>Has Goal</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasGoal()
	 * @generated
	 * @ordered
	 */
	protected EList<Goal> hasGoal;

	/**
	 * The cached value of the '{@link #getHasAdGoal() <em>Has Ad Goal</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasAdGoal()
	 * @generated
	 * @ordered
	 */
	protected EList<AdGoal> hasAdGoal;

	/**
	 * The cached value of the '{@link #getHasEvent() <em>Has Event</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasEvent()
	 * @generated
	 * @ordered
	 */
	protected EList<Event> hasEvent;

	/**
	 * The cached value of the '{@link #getHasOper() <em>Has Oper</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasOper()
	 * @generated
	 * @ordered
	 */
	protected EList<Operation> hasOper;

	/**
	 * The cached value of the '{@link #getHasEntity() <em>Has Entity</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasEntity()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> hasEntity;

	/**
	 * The cached value of the '{@link #getHasAgent() <em>Has Agent</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasAgent()
	 * @generated
	 * @ordered
	 */
	protected EList<Agent> hasAgent;

	/**
	 * The cached value of the '{@link #getHasAction() <em>Has Action</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasAction()
	 * @generated
	 * @ordered
	 */
	protected EList<Action> hasAction;

	/**
	 * The cached value of the '{@link #getHasCLink() <em>Has CLink</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasCLink()
	 * @generated
	 * @ordered
	 */
	protected EList<ContributionLink> hasCLink;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GoalDiagramImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GMPackage.Literals.GOAL_DIAGRAM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RefinementLink> getHasRLink() {
		if (hasRLink == null) {
			hasRLink = new EObjectContainmentEList<RefinementLink>(RefinementLink.class, this, GMPackage.GOAL_DIAGRAM__HAS_RLINK);
		}
		return hasRLink;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Goal> getHasGoal() {
		if (hasGoal == null) {
			hasGoal = new EObjectContainmentEList<Goal>(Goal.class, this, GMPackage.GOAL_DIAGRAM__HAS_GOAL);
		}
		return hasGoal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AdGoal> getHasAdGoal() {
		if (hasAdGoal == null) {
			hasAdGoal = new EObjectContainmentEList<AdGoal>(AdGoal.class, this, GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL);
		}
		return hasAdGoal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Event> getHasEvent() {
		if (hasEvent == null) {
			hasEvent = new EObjectContainmentEList<Event>(Event.class, this, GMPackage.GOAL_DIAGRAM__HAS_EVENT);
		}
		return hasEvent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Operation> getHasOper() {
		if (hasOper == null) {
			hasOper = new EObjectContainmentEList<Operation>(Operation.class, this, GMPackage.GOAL_DIAGRAM__HAS_OPER);
		}
		return hasOper;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getHasEntity() {
		if (hasEntity == null) {
			hasEntity = new EObjectContainmentEList<Entity>(Entity.class, this, GMPackage.GOAL_DIAGRAM__HAS_ENTITY);
		}
		return hasEntity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Agent> getHasAgent() {
		if (hasAgent == null) {
			hasAgent = new EObjectContainmentEList<Agent>(Agent.class, this, GMPackage.GOAL_DIAGRAM__HAS_AGENT);
		}
		return hasAgent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Action> getHasAction() {
		if (hasAction == null) {
			hasAction = new EObjectContainmentEList<Action>(Action.class, this, GMPackage.GOAL_DIAGRAM__HAS_ACTION);
		}
		return hasAction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ContributionLink> getHasCLink() {
		if (hasCLink == null) {
			hasCLink = new EObjectContainmentEList<ContributionLink>(ContributionLink.class, this, GMPackage.GOAL_DIAGRAM__HAS_CLINK);
		}
		return hasCLink;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GMPackage.GOAL_DIAGRAM__HAS_RLINK:
				return ((InternalEList<?>)getHasRLink()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_GOAL:
				return ((InternalEList<?>)getHasGoal()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL:
				return ((InternalEList<?>)getHasAdGoal()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_EVENT:
				return ((InternalEList<?>)getHasEvent()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_OPER:
				return ((InternalEList<?>)getHasOper()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_ENTITY:
				return ((InternalEList<?>)getHasEntity()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_AGENT:
				return ((InternalEList<?>)getHasAgent()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_ACTION:
				return ((InternalEList<?>)getHasAction()).basicRemove(otherEnd, msgs);
			case GMPackage.GOAL_DIAGRAM__HAS_CLINK:
				return ((InternalEList<?>)getHasCLink()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GMPackage.GOAL_DIAGRAM__HAS_RLINK:
				return getHasRLink();
			case GMPackage.GOAL_DIAGRAM__HAS_GOAL:
				return getHasGoal();
			case GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL:
				return getHasAdGoal();
			case GMPackage.GOAL_DIAGRAM__HAS_EVENT:
				return getHasEvent();
			case GMPackage.GOAL_DIAGRAM__HAS_OPER:
				return getHasOper();
			case GMPackage.GOAL_DIAGRAM__HAS_ENTITY:
				return getHasEntity();
			case GMPackage.GOAL_DIAGRAM__HAS_AGENT:
				return getHasAgent();
			case GMPackage.GOAL_DIAGRAM__HAS_ACTION:
				return getHasAction();
			case GMPackage.GOAL_DIAGRAM__HAS_CLINK:
				return getHasCLink();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GMPackage.GOAL_DIAGRAM__HAS_RLINK:
				getHasRLink().clear();
				getHasRLink().addAll((Collection<? extends RefinementLink>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_GOAL:
				getHasGoal().clear();
				getHasGoal().addAll((Collection<? extends Goal>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL:
				getHasAdGoal().clear();
				getHasAdGoal().addAll((Collection<? extends AdGoal>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_EVENT:
				getHasEvent().clear();
				getHasEvent().addAll((Collection<? extends Event>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_OPER:
				getHasOper().clear();
				getHasOper().addAll((Collection<? extends Operation>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_ENTITY:
				getHasEntity().clear();
				getHasEntity().addAll((Collection<? extends Entity>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_AGENT:
				getHasAgent().clear();
				getHasAgent().addAll((Collection<? extends Agent>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_ACTION:
				getHasAction().clear();
				getHasAction().addAll((Collection<? extends Action>)newValue);
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_CLINK:
				getHasCLink().clear();
				getHasCLink().addAll((Collection<? extends ContributionLink>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GMPackage.GOAL_DIAGRAM__HAS_RLINK:
				getHasRLink().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_GOAL:
				getHasGoal().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL:
				getHasAdGoal().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_EVENT:
				getHasEvent().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_OPER:
				getHasOper().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_ENTITY:
				getHasEntity().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_AGENT:
				getHasAgent().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_ACTION:
				getHasAction().clear();
				return;
			case GMPackage.GOAL_DIAGRAM__HAS_CLINK:
				getHasCLink().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GMPackage.GOAL_DIAGRAM__HAS_RLINK:
				return hasRLink != null && !hasRLink.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_GOAL:
				return hasGoal != null && !hasGoal.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_AD_GOAL:
				return hasAdGoal != null && !hasAdGoal.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_EVENT:
				return hasEvent != null && !hasEvent.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_OPER:
				return hasOper != null && !hasOper.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_ENTITY:
				return hasEntity != null && !hasEntity.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_AGENT:
				return hasAgent != null && !hasAgent.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_ACTION:
				return hasAction != null && !hasAction.isEmpty();
			case GMPackage.GOAL_DIAGRAM__HAS_CLINK:
				return hasCLink != null && !hasCLink.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //GoalDiagramImpl
